package com.bdqn.utli;

import org.apache.commons.mail.EmailException;
import org.apache.commons.mail.HtmlEmail;

public class EmailCheck {
	
	private static String hostName = "smtp.qq.com";//邮箱的SMTP服务器，一般123邮箱的是smtp.123.com,qq邮箱为smtp.qq.com
	private static String sender = "1984523567@qq.com";//发送者的邮箱-自己的邮箱
	private static String sendName = "授教网";//用户名-随便写
	private static String authorizationCode = "fvvyoszhepembgji";
	
	private static HtmlEmail email = new HtmlEmail();//创建HtmlEmali对象
	static {
		
		try {
			email.setHostName(hostName);
			email.setCharset("UTF-8");//设置发送的字符类型
			email.setFrom(sender,sendName);
			email.setAuthentication(sender,authorizationCode);
		} catch (EmailException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}
	
	public static void sendeCode(String recever,String subject,String mes) {
		try {
			email.addTo(recever);
			email.setSubject("请查看验证码");
			email.setMsg("验证码为："+mes);
			email.send();
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}
	public static void main(String[] args) {
		sendeCode("530981843@qq.com", "测试", "ceshocasdm");

	}
}
